package com.hna.eking.AirlineServer.Service;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;

import com.hna.eking.AirlineServer.Exception.RunServiceException;
import com.hna.eking.AirlineServer.Mapper.CountryInfo;
import com.hna.eking.AirlineServer.Mapper.CountryInfoMapper;

/**
 *
 * 国家表Service维护类 Date : 2018-9-13 Description: 国家表Service维护类 Copyright:
 * Copyright &copy; 2018 Company :aivac
 * 
 * @author APP BD lele
 * @version V1.0 修改历史 序号 日期 修改人 修改原因 1
 * 
 */

@Service
public class CountryInfoService {
	@Autowired
	private CountryInfoMapper Mapper;
	private Logger logger = LoggerFactory.getLogger(AirportInfoService.class);

	/*
	 * 查询指定国家列表
	 * 
	 * 参数： 无
	 * 
	 * 返回： 国家列表
	 *
	 */
	public List<CountryInfo> selectAllByCountryCode() throws RunServiceException {
		try {
			List<CountryInfo> ConntryList = Mapper.selectAllByCountryCode();

			/* 没有数据，返回无数据提示 */
			if (ConntryList == null || ConntryList.size() == 0) {
				throw new RunServiceException(RunServiceException.DATA_NOT_FOUND);
			}
			return ConntryList;
		} catch (DataAccessException e) {
			logger.error("database error");
			e.printStackTrace();
			throw new RunServiceException(RunServiceException.DATABASE_ERROR);
		}
		

	}
}
